package eatest;

import java.util.concurrent.TimeUnit;

public class EATest {

	private int total;

	private final int max;

	public EATest(int max) {
		super();
		this.max = max;
	}

	public static void main(String[] args) {
		// warmup
		new EATest(5000).execute();
		long t0 = System.nanoTime();
		new EATest(1000000000).execute();
		System.out.println("total time: "
				+ TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - t0));
	}

	public void execute() {
		for (int i = 0; i < max; i++) {
			innerMethod2(i);
		}
	}

	public void sInnerMethod(int i) {
		Foo foo = new Foo();
		synchronized (foo) {
			foo.setNumA(i);
			foo.setNumB(i * i);
		}
		total += foo.sum();
	}

	public void innerMethod(int i) {
		Foo foo = new Foo();
		foo.setNumA(i);
		foo.setNumB(i * i);
		total += foo.sum();
	}

	public void innerMethod2(int i) {
		VFoo foo = new VFoo();
		foo.setNumA(i);
		foo.setNumB(i * i);
		total += foo.sum();
	}

}
